package main

import (
	"fmt"
	"time"
)
var channel  chan string = make(chan string)
var channel2 chan string = make(chan string)
var channelI chan int = make(chan int, 3)

func loop(s string)  {
	fmt.Println(s)
	for i:=0; i<5; i++ {
		fmt.Println(i)
	}
}
func testLoop()  {
	go loop("routines:")
	loop("bb:")
	time.Sleep(time.Second)
}
func setChannel(s string)  {
	fmt.Println(s)
	channel <- s
}
func testChannel(s string)  {
	fmt.Println(s)
	channel2 <- s
	channel <- <- channel2
}
func foo(id int)  {
	channelI <- id
}
func main() {
	go testChannel("Php")
	fmt.Println("Golang")
	<- channel2
	fmt.Println(len(channel))

	for i:=0; i<5; i++ {
		go foo(i)
	}

	for v := range channelI{
		fmt.Println(v)
		if len(channelI) <= 0 {
			break
		}
	}
}